package com.waidi.clothespad.ui;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.AdapterView;
import com.smartown.tableview.library.TableView;
import com.waidi.clothespad.R;
import com.waidi.clothespad.adapter.BaseInfoAdapter;

import butterknife.BindView;
import butterknife.Unbinder;



/**
 * Created by ll on 2018-07-25.
 */

public class SalaryDialog extends Dialog {

    private Context mContext;
    public GridView gridView = null;
    public BaseInfoAdapter myadapter=null;
    public SalaryDialog(@NonNull Context context)
    {
        super(context);
        this.mContext = context;
    }

    private void init()
    {

        myadapter = new BaseInfoAdapter(mContext,null);
        gridView.setAdapter(myadapter);
        myadapter.notifyDataSetChanged();


        // gridview的item的点击事件  OnItemClickListener
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
               // Log.i("onItemClick", Integer.toString(position));
               // Toast.makeText(context, Integer.toString(position), Toast.LENGTH_LONG).show();
                myadapter.setSeclection(position);
                myadapter.notifyDataSetChanged();
            }
        });

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*
        setContentView(R.layout.layer_system_setting);
        ButterKnife.bind(this);
        */
        View view = LayoutInflater.from(mContext).inflate(R.layout.salarydialog, null);
        setContentView(view);

        gridView = (GridView)view.findViewById(R.id.gridView);
        setContentView(view);


        Window dialogWindow = getWindow();
        WindowManager manager = ((Activity) mContext).getWindowManager();
        WindowManager.LayoutParams params = dialogWindow.getAttributes(); // 获取对话框当前的参数值
        dialogWindow.setGravity(Gravity.CENTER);//设置对话框位置
        Display d = manager.getDefaultDisplay(); // 获取屏幕宽、高度
        params.width = (int) (d.getWidth() * 0.7); // 宽度设置为屏幕的0.65，根据实际情况调整
        params.height = (int) (d.getHeight() * 0.9); // 宽度设置为屏幕的0.65，根据实际情况调整
        dialogWindow.setAttributes(params);


        init();
    }


}
